// .txt

beginzonescript;

variables;

short crime_tolerance = 3;
short last_abil;
short i;
short count1 = 0;
short count2 = 0;
short count3 = 0;

body;

beginstate INIT_STATE;

	set_name(21,"Captain Reigert");
	
	set_name(25,"Bounty Hunter");
	set_level(25,15);
	set_name(26,"Bounty Hunter");
	set_level(26,15);
	
	set_name(27,"Giselle");
	set_level(27,12);
	set_boss_level(27,1);
	
	set_name(36,"Hartwin");

	add_range_to_group(21,24,1);
	add_range_to_group(28,35,2);

	add_range_to_group(37,44,3);
	set_name(1003,"Crystal Shade");
	set_level(1003,20);
	set_aggression(1003,8);
	
	set_name(45,"Possessed Rat");
	set_name(46,"Possessed Rat");
	set_name(47,"Possessed Rat");
	set_name(48,"Possessed Rat");

	if (get_sdf(38,6) > 0) {
		make_zone_hostile();
		}

	last_abil = get_current_tick();
	
	set_crime_tolerance(crime_tolerance);
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	// clear zone?
	//if ((zone_clear(ME) == FALSE) && (get_flag(,) > 0)) {
		//print_str_color("",2);
		//clear_zone(ME);	
		//}
		
	if ((get_crime_level() >= crime_tolerance) && (get_sdf(38,6) == 0)) {
		make_zone_hostile();
		set_flag(38,6,1);
		}

	 if (gf(38,6) == 0) {
		if (num_chars_in_group(2) > 0) {
			if (get_ran(1,0,100) < 10)
				give_char_text_bubble(27,"Help me!");
			if (get_ran(1,0,100) < 10)
				give_char_text_bubble(27,"They're in there!");
			}
		if (num_chars_in_group(2) == 0) {
			if (get_ran(1,0,100) < 10)
				give_char_text_bubble(27,"Many thanks.");
			if (get_ran(1,0,100) < 10)
				give_char_text_bubble(27,"Need a drink?");
			}
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(25 + get_ran(1,0,1),"Mutter.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(25 + get_ran(1,0,1),"Mutter, mutter.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(25 + get_ran(1,0,1),"Someone's listening.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(36,"Scrapey scrapey.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(36,"Pesky little hairs.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(36,"Good ornk. Yes.");
		}
	
	if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || ((is_group()) && (tick_difference(last_abil,get_current_tick()) > 5))) {
		if (gf(38,3) == 0) {
			if (party_near_nav(0,4)) {
				count1 = count1 + 1;
				if (count1 == 2) {
					sf(38,3,1);
					activate_hidden_group(1);
					begin_talk_mode(5);
					}
					else print_str_color("You hear a scratching noise coming from somewhere nearby.",2);
				}
				else count1 = 0;
			}
		if (gf(38,4) == 0) {
			if (party_near_nav(1,4)) {
				count2 = count2 + 1;
				if (count2 == 2) {
					sf(38,4,1);
					activate_hidden_group(2);
					begin_talk_mode(6);
					}
					else print_str_color("You hear a scratching noise coming from somewhere nearby.",2);
				}
				else count2 = 0;
			}
		if (gf(38,5) == 0) {
			if (party_near_nav(2,5)) {
				count3 = count3 + 1;
				if (count3 == 4) {
					sf(38,5,1);
					activate_hidden_group(3);
					begin_talk_mode(6);
					}
					else print_str_color("You hear a scratching noise coming from somewhere nearby.",2);
				}
				else count3 = 0;
			}
			
		
		last_abil = get_current_tick();
		}
break;

beginstate 10;
	set_terrain_string_range("It looks like several people were camping here for a while. They left a few weeks ago. In a hurry, from the looks of things.",3);
break;

beginstate 11;
	set_terrain_string_range("The sign says - The Three Kegs Inn.",3);
break;

//	print_str("");
//	set_terrain_string_range(".",3);
//	set_terrain_string_range("The sign says - .",3);
